package myTest.syntax

import myTest.classAndInterface.Person
import myTest.enumPackage.Gender
import java.util.*

fun main(args: Array<String>) {

    //..表示区间，区间是闭合的，左右极限值都包含
//    for (i in 1..100){
//        println(i)
//    }

    //正序递增，不包含最大值
//    for (i in 1 until 100){
//        println(i)
//    }

    //逆序递减，包含左右值
//    for (i in 100 downTo 1){
//        println(i)
//    }

    //从1开始步长2，不超过最大值
//    for (i in 1..100 step 2){
//        println(i)
//    }

//    val f = For()
//    f.add()
//    f.getIndex()

    //生成List
    val list = arrayListOf(Person(1, "", Gender.MAN), Person(2, "666", Gender.WOMEN))
    //list.withIndex()索引遍历
    for ((index,value) in list.withIndex()){
        println("$index=====$value")
    }

}



class For{

    val binaryMap= TreeMap<Char,String>()

    fun add(){
        for (c in 'A'..'F'){

            //c.toInt():char-->asciiCode,
            // Integer.toBinaryString:asciiCode-->String
            val cString = Integer.toBinaryString(c.toInt())
            binaryMap[c]=cString
        }
    }

    fun get(){

        //letter是键，binary是值
        for ((letter,binary) in binaryMap){
            println("键:$letter-------值：$binary")
        }
    }



}



